source('/home/jc148322/scripts/libraries/cool_functions.r')
library(SDMTools)

wd='/home/jc148322/frog_declines/SDM/regular/';setwd(wd)
out.dir='/home/jc148322/frog_declines/SDM/regular/images/';dir.create(out.dir)

species=list.files('/home/jc148322/frog_declines/SDM/regular/Post_decline/models/')

cols=colorRampPalette(c('tan','forestgreen','olivedrab2'))(100)
timelines=c('Pre_decline','Post_decline')
tasc=read.asc.gz('/home/jc148322/frog_declines/SDM/Post_decline/models/dayi/output/ascii/current.76to05.asc.gz')
for (spp in species) { cat(spp,'\n')
	png(paste(out.dir,spp,'.test.png',sep=''),width=dim(tasc)[1]*2, height=dim(tasc)[2], units='px', pointsize=20, bg='white')
	par(mfrow=c(1,2),mar=c(1,1,1,1))
	for (tt in timelines){
		spp.dir=paste(wd,tt,'/models/',spp,'//',sep='');setwd(spp.dir)
		
		tasc=read.asc.gz('output/ascii/current.76to05.asc.gz')

		occur=read.csv('occur.csv',as.is=T)
		
		image(tasc,ann=F,axes=F,col=cols,zlim=c(0,1))
		points(occur$long,occur$lat,pch=16)
		
	}
	dev.off()
}


